import Cookies from 'js-cookie'
// cookie保存的天数
import defaultSettings from '@/defaultSettings'
const {cookieExpires} = defaultSettings

export const TOKEN_KEY = 'token'

export function getToken() {
  const token = Cookies.get(TOKEN_KEY)
  if (token) return token
  else return false
}

export function setToken(token) {
  return Cookies.set(TOKEN_KEY, token, { expires: cookieExpires || 1 })
}

export function removeToken() {
  return Cookies.remove(TOKEN_KEY)
}